package cn.uexpo.lhz.biz.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



import cn.uexpo.lhz.biz.CamerastatusBiz;
import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.dao.CamerastatusMapper;
import cn.uexpo.lhz.domain.Camerastatus;
import cn.uexpo.lhz.domain.CamerastatusExample;

@Transactional
@Service
public class CamerastatusBizImpl implements CamerastatusBiz {

	@Autowired
	private CamerastatusMapper statusMapper;
	@Override
	public int insert(Camerastatus record) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.insert(record);
	}

	@Override
	public int insertSelective(Camerastatus record) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.insertSelective(record);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int deleteEntity(Camerastatus record) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.deleteByPrimaryKey(record.getId());
	}

	@Override
	public int deleteByIds(List<Integer> ids) throws BOException {
		// TODO Auto-generated method stub
		for (Integer id : ids) {
			statusMapper.deleteByPrimaryKey(id);
		}
		return 1;
	}

	@Override
	public int delete(List<Camerastatus> records) throws BOException {
		// TODO Auto-generated method stub
		for (Camerastatus record : records) {
			statusMapper.deleteByPrimaryKey(record.getId());
		}
		return 1;
	}

	@Override
	public int deleteByExample(CamerastatusExample example) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.deleteByExample(example);
	}

	@Override
	public int updateByPrimaryKey(Camerastatus record) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(Camerastatus record) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByExampleSelective(Camerastatus record, CamerastatusExample example) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.updateByExampleSelective(record,example);
	}

	@Override
	public int updateByExample(Camerastatus record, CamerastatusExample example) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.updateByExample(record,example);
	}

	@Override
	public Camerastatus selectByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.selectByPrimaryKey(id);
	}

	@Override
	public Camerastatus selectByUniqueCode(String uniqueCode) throws BOException {
		// TODO Auto-generated method stub
		Camerastatus item=null;
		CamerastatusExample example=new CamerastatusExample();
		CamerastatusExample.Criteria citeria=example.createCriteria();
		 citeria.andExtstr3EqualTo(uniqueCode);
		 List<Camerastatus> items=statusMapper.selectByExample(example);
		 if (items!=null&&items.size()>0) {
			 item=items.get(0);
		}
		return item;
	}

	@Override
	public List<Camerastatus> selectByExample(CamerastatusExample example) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.selectByExample(example);
	}

	@Override
	public long countByExample(CamerastatusExample example) throws BOException {
		// TODO Auto-generated method stub
		return statusMapper.countByExample(example);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest, CamerastatusExample example) throws BOException {
		int pageNum = pageRequest.getPage();
	    int pageSize = pageRequest.getLimit();
	    PageHelper.startPage(pageNum, pageSize);
	    List<Camerastatus> records = (List<Camerastatus>) statusMapper.selectByExample(example);
	    return PageUtils.getPageResult(pageRequest, new PageInfo<Camerastatus>(records));
	}

}
